﻿using System;
using Bintje.bintje;
using System.Collections.Generic;

namespace Bintje
{
    public class Annotation : RepoObject
    {
        #region Fields

        private string m_comment;
        private string m_email;
        private string m_name;
        private int m_userId;
        private bool m_read;
        private long m_created1;
        private long m_modified1;

        #endregion
        
        #region Properties

        public int UserId
        {
            get { return m_userId; }
            set { m_userId = value; }
        }

        public string Name
        {
            get { return m_name; }
            set { m_name = value; }
        }

        public string Email
        {
            get { return m_email; }
            set { m_email = value; }
        }

        public string Comment
        {
            get { return m_comment; }
            set { m_comment = value; }
        }

        public bool Read
        {
            get { return m_read; }
            set { m_read = value; }
        }

        public long Modified1
        {
            get { return m_modified1; }
            set { m_modified1 = value; }
        }

        public long Created1
        {
            get { return m_created1; }
            set { m_created1 = value; }
        }

        #endregion

        #region ctor
        public Annotation()
        {

        }
        public Annotation(annotation annotation)
        {
            m_comment = annotation.comment;
            m_email = annotation.email;
            m_name = annotation.name;
            m_id = annotation.id;
            m_userId = annotation.userId;
            m_read = annotation.read;
        } 

        #endregion

        #region Methods

        internal annotation ConvertToAPI()
        {
            annotation annotation = new annotation();
            annotation.comment = this.Comment;
            annotation.email = this.Email;
            annotation.id = this.Id;
            annotation.name = this.Name;
            annotation.userId = this.UserId;
            annotation.read = this.Read;
            return annotation;
        }

        internal static annotation[] ConvertToAPI(IList<Annotation> annotationsList)
        {
            annotation[] annotations = (annotation[])Array.CreateInstance(typeof(annotation), annotationsList.Count);
            for (int i = 0; i < annotationsList.Count; i++)
            {
                annotations[i] = annotationsList[i].ConvertToAPI();
            }
            return annotations;
        } 

        #endregion
    }
}
